package com.person.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.person.model.entity.ComplaintInfo;
import com.person.model.entity.Result;
import com.person.model.vo.ComplaintBaseInfoVo;
import com.person.model.vo.ComplaintInfoVo;
import com.person.service.ComplaintInfoService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

@RequestMapping("/complaint_info")
@RestController
public class ComplaintInfoController {

    @Resource
    private ComplaintInfoService complaintInfoService;

    @PostMapping("/get_list")
    public Result getComplaintInfo(@RequestParam Integer current, @RequestParam Integer size, @RequestBody(required = false) ComplaintInfoVo complaintInfoVo) {
        Page<ComplaintInfo> page = new Page<>(current, size);
        Page<ComplaintInfo> complaintInfos = complaintInfoService.pageItem(page, complaintInfoVo);
        return Result.success(complaintInfos);
    }

    @PostMapping("/add_or_update")
    public Result addOrUpdateComplaintInfo(@RequestBody ComplaintBaseInfoVo complaintBaseInfoVo) {
        complaintInfoService.addOrUpdateComplaintInfo(complaintBaseInfoVo);
        return Result.success();
    }
}
